package edu.erpan.fachada;

import java.util.List;
import com.ibytecode.util.JNDILookup;
import edu.erpan.bl.bean.MaquinariaBean;
import edu.erpan.bl.bean.MaquinariaBeanRemote;
import edu.erpan.bl.entities.Maquinaria;
import edu.erpan.util.entityManager.exceptions.IdNotFoundException;
import edu.erpan.util.entityManager.exceptions.PersistException;
import edu.erpan.util.entityManager.exceptions.QueryException;

public class MaquinariaFachada implements IMaquinariaFachada{

	@SuppressWarnings("unchecked")
	@Override
	public List<Maquinaria> consultarMaquinaria() throws QueryException{
		MaquinariaBeanRemote<Maquinaria> maquinariaBean=JNDILookup.doLookup(MaquinariaBean.class, MaquinariaBeanRemote.class);
		return maquinariaBean.retrieveAllEntities();
	
	}
	@SuppressWarnings("unchecked")
	@Override
	public void guardaMaquina(Maquinaria maquinaria) throws PersistException{
		MaquinariaBeanRemote<Maquinaria> maquinariaBean=JNDILookup.doLookup(MaquinariaBean.class, MaquinariaBeanRemote.class);
		maquinariaBean.saveEntity(maquinaria);
	}
	@SuppressWarnings("unchecked")
	@Override
	public Maquinaria consultarMaquina(Maquinaria maquinaria) throws QueryException, IdNotFoundException {
		// TODO Auto-generated method stub
		MaquinariaBeanRemote<Maquinaria> maquinariaBean=JNDILookup.doLookup(MaquinariaBean.class, MaquinariaBeanRemote.class);
		return maquinariaBean.findEntity(maquinaria);
	}
	@SuppressWarnings("unchecked")
	@Override
	public void borraMaquina(Maquinaria maquinaria) throws IdNotFoundException, QueryException{
		// TODO Auto-generated method stub
		MaquinariaBeanRemote<Maquinaria> maquinariaBean=JNDILookup.doLookup(MaquinariaBean.class, MaquinariaBeanRemote.class);
		maquinariaBean.deleteEntity(maquinaria);
	}
	@SuppressWarnings("unchecked")
	@Override
	public void editarMaquina(Maquinaria maquinaria) throws QueryException, IdNotFoundException{
		MaquinariaBeanRemote<Maquinaria> maquinariaBean=JNDILookup.doLookup(MaquinariaBean.class, MaquinariaBeanRemote.class);
		maquinariaBean.mergeEntity(maquinaria);
	
	}
	@SuppressWarnings("unchecked")
	@Override
	public List<Maquinaria> revisaMaquinas() throws QueryException{
		MaquinariaBeanRemote<Maquinaria> maquinariaBean=JNDILookup.doLookup(MaquinariaBean.class, MaquinariaBeanRemote.class);
		return maquinariaBean.datosRMaquinas();
	
	}
	


}
